uniform mat4 uWorldViewMatrix;
uniform mat4 uNormalViewMatrix;
uniform mat4 uPerspectiveMatrix;
uniform vec3 uLightpos0;
attribute vec3 position;
attribute vec3 normal;
void main()
{
vec3 N = normalize((uNormalViewMatrix * vec4(normal, 0.0)).xyz);
vec4 PosView = uWorldViewMatrix * vec4(position, 1.0);
vec3 LightVecView = PosView.xyz - uLightpos0;
if( dot( N, -LightVecView ) < 0.0 )
{
if( PosView.z > uLightpos0.z )
PosView.xyz += LightVecView * ( 300.0 - PosView.z ) / LightVecView.z;
else
PosView = vec4( LightVecView, 0.0 );
}
gl_Position = uPerspectiveMatrix * PosView;
}